Skip to content

1 Installation

F-WebShop

The installation chapter is of course a comprehensive guide to installing F-Webshop on your machine.

Installation via Vagrant

Vagrant is a tool for building complete development environments, that in case of F-Webshop will help you to quickly have full application running on your machine.

  • Clone the project
git clone git@gitlab.fsd.rs:Beograd-e-commerce/Empire-With-Plugin.git f-webshop
  • Go to Vagrant folder
cd f-webshop/Vagrant;
  • Install vagrant-dns plugin dependencies
#Also, read more at https://github.com/BerlinVagrant/vagrant-dns
vagrant plugin install vagrant-dns
  • Run vagrant up command
vagrant up
  • Enter vagrant machine
vagrant ssh
  • Go to project root directory and run shell deploy script
cd /var/www/instances/fwebshop.home;
./instance_deploy.sh Demo Empire-Backend root root 127.0.0.1 3306 demo_database fwebshop.home no php7.1 yes

Docker installation

Docker use containers to separate application from the OS environment.

It consists of:

  • docker-compose.yml file
  • ./docker/Dockerfile
  • ./docker/application
  • ./docker/logs
  • ./docker/mysql
  • ./docker/php
  • ./docker/redis
  • ./docker/vhosts
  • ./docker/xdebug

We have to build container for the application.

Prerequisites

To set up all properly it is necessary to install docker engine on your host OS.

Installing

Depending on your operating system see how to set up Docker on your host. Read more about it on:

https://docs.docker.com/engine/installation/

Check if docker is successfully installed on the host with command:

docker --version

Also install docker-compose on your host. Read more about it on:

https://docs.docker.com/compose/install/

Main parts

In root directory of Docker for webshop app, docker-compose.yml file is stored. All general settings for our docker containers are coded in that file.

Each container has its own name, port, ip etc.

In directory:

./docker/

is located Dockerfile which is main config file for all docker containers! In our case, one. All dependencies that are going to be installed on container creation are coded in.

In directory:

./docker/scripts

There is a script that executes after container creation. Usually for starting services etc.

Application code

In directory:

./docker/application

is located application code. It can be edited outside the container. All the dependencies are in the container. Git commands, composer etc. can be executed outside the container.

Services config files

In directory:

./docker/logs

are located nginx logs from docker container.

In directory:

./docker/mysql

are stored credencials for mysql database. Important! Changed credencials in this file should be also changed in ./docker/Dockerfile (mysql install part, debconf-set-selection) It is necessary to re-crecate docker container and docker image, so changes can be applied.

In directory:

./docker/php

is stored php.ini file with specific changes for the application.

In directory:

./docker/redis

is stored Redis main config with specific changes for the application.

In directory:

./docker/vhosts

are stored nginx vhost files. Those vhosts are going to be enabled on every container start. It can be changed or added new ones outside the container.

In directory:

./docker/xdebug

Currently there is nothing. It is still in development because of issues with installing xdebug inside the container.

In directory:

./docker/nginx

is located main Nginx config file.

How it works

docker-compose create container as it is configured in Dockerfile.

Run

To run docker container/s:

Locate in directory where is docker-compose.yml file and run following command:

docker-compose up -d

We use -d to run Docker command in the background.

Docker container successfully up and running!

To stop docker container/s:

docker-compose down

Important

Try always to use 'docker-compose down' command to shutdown containers because it stops everything clearly.

If you were using 'docker stop' command to stop one or more containers, use again 'docker-compose up -d' to run everything, even if there are some running containers.

All services config files are copied during container build and permanently added in docker image. So if there are some changes it is necessary to re-create docker image and docker containers. 1. docker-compose down 2. docker rmi IMAGE_ID 3. docker-compose up -d

During container creation also one user is created. This user (webshop) is owner on application code (files) inside the container. It has the same id as your user on your machine, so all changes outside the container can be eddited (e.g. from PHP Storm).

Docker container use specific port. It is useful because, usually all webservers use port 80 as default. You don't have to care about other webservers on host because you have your custom. In this case port 901. Access docker web conntent from browser: e.g. http://msimic-test2.office.fsd.rs:801/app_dev.php

Also it is possible to add specific commands to be executed on container start. e.g. composer install, execute migrations etc

Good to know

Use docker command to view ip addresses of containers List of all active containers on host:

docker ps -a

View ip address of a specific container:

docker inspect CONTAINER_ID 

Run docker command to stop specific container:

docker stop CONTAINER_ID

Run docker command to remove specific container:

docker rm CONTAINER_ID

Run the app

To enter the specific container:

docker exec -i -t CONTAINER_ID /bin/bash

To enter the specific container:

docker exec -i -t CONTAINER_ID /bin/bash

Then, navigate to project directory and run shell deploy script

cd /srv/fsd/new-empire/;
./instance_deploy.sh Demo Empire-Backend root miniini1 127.0.0.1 3306 demo_database fwebshop.home no php7.1 yes

Remote installation

Prefered way to install dependencies packages for F-Webshop on Debian system is using ansible.

Depending on your operating system see how to set up Docker on your host. Read more about it on:

https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html
  • From the app root folder run this in your shell:
#Replace it with your own ip or domain
stagingServer=10.10.12.21
#If you want, replace it with your own root folder
nginx_dir=/var/www/instances
#Replace it with your ssh user
sshUser=root
multiInstance=yes
ansible-playbook -i "${stagingServer}," Vagrant/ansible/production.yml --extra-vars "SERVER_IP=${stagingServer} varnish=no nginx_root=${nginx_dir} multi_instance=${MULTI_INSTANCE} mysql_user_root=root mysql_user_root_pass=root_pwd"
  • Rsync files from local machine to remote root folder
rsync -a --no-perms --no-owner --no-group --progress  --exclude=".git" --exclude-from='.gitignore' ./ ${sshUser}@${stagingServer}:${nginx_dir}/{stagingServer};
  • Login to your server using ssh
ssh ${sshUser}@${stagingServer}
  • Go to app root folder and run shell deploy script
#Theme to be deployed
theme=Demo
#Note: 10.10.12.21 is stagingServer from previous step
cd /var/www/instances/10.10.12.21;
./instance_deploy.sh ${theme} Empire-Backend root root_pwd 127.0.0.1 3306 demo_database 10.10.12.21 no php7.1 yes

  • Give Access rights
./give_permission.sh  ${theme}